package thread;

public class Demo12 {
    public static boolean isQuite = false;

    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> {
            while (!isQuite) {
                System.out.println("Hello thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }

        });
        t.start();

        Thread.sleep(5000);
        System.out.println("main线程尝试终止t线程");
        isQuite = true;
    }
}
